{include file="common/mainHead"/}
<div class="admin-main fadeInUp animated">
    <fieldset class="layui-elem-field">
        <legend>备份文件列表</legend>
        <div class="layui-field-box table-responsive">
            <table class="site-table table-hover">
                <thead>
                <tr>
                    <th>文件名称</th>
                    <th>文件大小</th>
                    <th>备份时间</th>
                    <th>卷号</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {foreach name="vlist" item="vo" key="k" }
                <tr>
                    <td>{$vo.name}</td>
                    <td>{$vo.size|byte_format}</td>
                    <td>{$vo.time|toDate}</td>
                    <td>{$vo.number}</td>
                    <td>
                        <a href="javascript:;" onclick="return recover('{$vo['name']}');" class="layui-btn layui-btn-normal layui-btn-mini">恢复</a>
                        <a href="{:url('downFile',array('type'=>'sql','file'=>$vo['name']))}" class="layui-btn layui-btn-mini">下载</a>
                        <a href="javascript:;" onclick="return del('{$vo['name']}');" class="layui-btn layui-btn-danger layui-btn-mini">删除</a>
                    </td>
                </tr>
                {/foreach}
                </tbody>
            </table>

        </div>
    </fieldset>
    <div class="admin-table-page">
        <div id="page" class="page">
        </div>
    </div>
</div>
{include file="common/mainFoot"/}
<script>
    layui.use('layer', function() {
        var layer = parent.layer === undefined ? layui.layer : parent.layer;
    });
    function recover(name) {
        layer.confirm('确认要导入数据吗？',{icon: 0}, function () {
            $.post("{:url('restoreData')}",{sqlfilepre:name},function(data){
                if(data.code==1){
                    layer.msg(data.msg, {time: 1800});
                }else{
                    layer.msg(data.msg,{time: 1800});
                }
            });
        });
    }
    function del(name) {
        layer.confirm('确认要删除该备份文件吗？', {icon: 3}, function () {
            $.post('{:url("delSqlFiles")}',{sqlfilename: name}, function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg, {time: 1800}, function(){
                        window.location.href=data.url;
                    });
                }else{
                    layer.msg(data.info,{time: 1800});
                }
            });
        });
    }
</script>